package com.easy.service.impl;

import com.easy.bean.Admin;
import com.easy.bean.User;
import com.easy.dao.AdminDao;
import com.easy.service.ISystemLoginService;
import com.easy.util.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class SystemLoginService implements ISystemLoginService {
    @Autowired
    AdminDao adminDao;

    @Override
    public Admin dologin(Admin admin) {
        Admin admin_data=adminDao.getAdminByUsername(admin.getUsername());
        if(admin_data==null){
            throw new RuntimeException("没有此账号");
        }
        if(!admin.getPassword().equals(admin_data.getPassword())){
            throw new RuntimeException("密码不正确");
        }
        return admin_data;
    }

    @Override
    public int getCount1(String text) {
        return adminDao.getCount1(text);
    }

    @Override
    public List<Admin> getList1(Page page, String text) {
        return adminDao.getList1(page,text);
    }

    @Override
    public int add(Admin admin) {
        return adminDao.add(admin);
    }

    @Override
    public int edit(Admin admin) {
        return adminDao.edit(admin);
    }

    @Override
    public int delete(int adminid) {
        return adminDao.delete(adminid);
    }


}
